import React, {Component} from 'react';
import moment from "moment";
import URLS from '@/apis/APIUrlDefine';
import { Comment, Tooltip, Avatar } from 'antd';

interface IComment {
    comment: any;
    reply: any
}


class CommentItem extends Component<IComment, any> {
    constructor(props:IComment) {
        super(props);
        this.state = {
            action: ""
        }
    }

    render() {
        const comment = this.props.comment;
        const reply = this.props.reply;
        return (
            <Comment
                author={<span>{reply === null ? comment?.nickname : comment?.nickname + "回复" + reply}</span>}
                avatar={
                    <Avatar
                        src={`${URLS.SERVER_PICTURE_URL  + comment?.avatarUrl}`}
                        alt=""
                    />
                }
                content={
                    <p>
                        {
                            comment?.content
                        }
                    </p>
                }
                datetime={
                    <span>{moment(comment.createdTime).fromNow()}</span>
                }
            >
                {this.props.children}
            </Comment>
        );
    }
}

export default CommentItem;